package marmalius;

public class Buttons {
	public static Methods Methods;
	
	static {
		Methods = new Methods(0);
	}
	
	public void buttons(int ID) {
		client c = (client) PlayerHandler.getInstance().getPlayer(ID);
		server.woodcutting.ResetWoodCutting(c);
		server.mining.ResetMining(c);
		c.stopFishing();
		switch (c.actionButtonId) {
			case 9157:
				if (c.chooseMiniGame) {
					c.teleportToX = 3233;
					c.teleportToY = 9315;
					c.heightLevel = 0;
					c.sendMessage("You teleport to the GodSword MiniGame!");
					c.chooseMiniGame = false;
				}
				break;
			/* Loop/switch isn't completed */
			case 34185: 
			case 34189: 
			case 34193: 
				server.Cooking.orMaybeNow(c.playerId);
				break; /* Loop/switch isn't completed */
			case 33206:
				server.MenuHandler.attackMenu(c.playerId);
				break;
			case 7053:
				c.iceBarrageSet = true;
				break;
			case 34142:
				server.MenuHandler.strengthMenu(c.playerId);
				break;
			case 33209:
				server.MenuHandler.strengthMenu(c.playerId);
				break;
			case 33212:
				server.MenuHandler.defenceMenu(c.playerId);
				break;
			case 34119:
				server.MenuHandler.defenceMenu(c.playerId);
				break;
			case 33215:
				server.MenuHandler.rangeMenu(c.playerId);
				break;
			case 34120:
				server.MenuHandler.rangeMenu(c.playerId);
				break;
			case 33221:
				server.MenuHandler.mageMenu(c.playerId);
				break;
			case 34123:
				server.MenuHandler.mageMenu(c.playerId);
				break;
			case 33218:
				server.MenuHandler.prayMenu(c.playerId);
				break;
			case 33224:
				server.MenuHandler.runecraftMenu(c.playerId);
				break;
			case 33210:
				server.MenuHandler.agilityMenu(c.playerId);
				break;
			case 9158:
				// end of easter event by dan
				break; 
			case 3189:
				break;
			case 47093:
				c.closeInterface();
				break;
			// case 4126: windstrike break;
			/* FLETCHING START */
			case 51039:
				c.CastVengeance(); 
				break;
			case 29063: // axes
				if (c.specialAmount >= c.needSpecialAmount()) {
					if (Methods.isSpecWeapon(c.playerEquipment[c.playerWeapon])) {
						Methods.specialAttacks2(c.playerId);
						Methods.specialAttacks3(c.playerId);
						Methods.specialAttacks4(c.playerId);
						Methods.specialAttacks(c.playerId);
					}
					else if (Methods.isSpecWeapon(c.playerEquipment[c.playerWeapon])) {
						c.usingSpecial = false;
					}
				}
				else if (c.specialAmount < c.needSpecialAmount()) {
					c.usingSpecial = false;
				}
				break;
			case 33033: // halberds
			case 29113: // bows
			case 29163: // swords
			case 29138: // dds
			case 48023: // whip
				try {
					if (c.specialAmount >= c.needSpecialAmount()) {
						if (c.usingSpecial == true) {
							c.usingSpecial = false;
						}
						else if (c.usingSpecial == false) {
							c.usingSpecial = true;
						}
						Methods.specialAttacks2(c.playerId);
						Methods.specialAttacks3(c.playerId);
						Methods.specialAttacks4(c.playerId);
						Methods.specialAttacks(c.playerId);
					}
					else if (c.specialAmount < c.needSpecialAmount()) {
						c.usingSpecial = false;
					}
				}
				catch (Exception popo) {}
				break;
			case 4169: // charge spell
				if (c.playerLevel[6] > 79) {
					if ((c.playerHasItemAmount(554, 3) == false) || (c.playerHasItemAmount(4278, 3) == false) || (c.playerHasItemAmount(556, 3) == false)) {
						c.sendMessage("You do not have enough runes to cast this spell.");
					}
					else if ((c.playerHasItemAmount(554, 3) == true) || (c.playerHasItemAmount(4278, 3) == true) || (c.playerHasItemAmount(556, 3) == true)) {
						if (c.charge == 0) {
							c.charge = 1;
							c.sendMessage("You feel charged with a magical power !");
							c.stillgfx(308, c.absY, c.absX);
							c.startAnimation(811);
							c.teleportToX = c.absX;
							c.teleportToY = c.absY;
							c.addSkillXP((112 * c.playerLevel[6]), 6);
							c.deleteItem(554, c.getItemSlot(554), 3); 
							c.deleteItem(4278, c.getItemSlot(4278), 3); 
							c.deleteItem(556, c.getItemSlot(556), 3);
						}
						else if (c.charge >= 1) {
							c.sendMessage("You are allready charged !");
						}
					}
					else {
						c.sendMessage("You need a magic level of 80 to cast this spell");
					}
				}
				break;
			/* FLETCHING END */
			case 14067: // Char design accept button
				c.RemoveAllWindows();
				break;
			/* CRAFTING STUFF */	
			case 153:
				if (c.playerEnergy > 0) {
					c.isRunning2 = true;
				}
				break;
			case 152:
				c.isRunning2 = false;
				break;
			case 130: // close interface
				c.println_debug("Closing Interface");
				break;
			case 168: // Skill Capes
				if (c.actionTimer <= 0) {
					if (c.playerEquipment[c.playerCape] == 3777) {
						c.actionTimer = 8;
						c.startAnimation(1914);
						c.gfx100(481);
						c.txt4 = "I Feal My Awsome Strength!!!";
					}
					if (c.playerEquipment[c.playerCape] == 4327) { // firemaking ???
						c.startAnimation(1502);
						c.stillgfx(446, c.absY + 1, c.absX);
						c.stillgfx(446, c.absY - 1, c.absX);
						c.stillgfx(446, c.absY, c.absX + 1);
						c.stillgfx(446, c.absY, c.absX - 1);
						c.stillgfx(453, c.absY + 1, c.absX);
						c.stillgfx(453, c.absY - 1, c.absX);
						c.stillgfx(453, c.absY, c.absX + 1);
						c.stillgfx(453, c.absY, c.absX - 1);
						c.actionTimer = 8;
					}
					if (c.playerEquipment[c.playerCape] == 4317) { // slayer
						c.stillgfx(466, c.absY, c.absX);
						c.stillgfx(468, c.absY, c.absX);
						c.actionTimer = 8;	   
					}
					if (c.playerEquipment[c.playerCape] == 4315) { // runecrafting
						c.actionTimer = 8;
						c.stillgfx(601, c.absY, c.absX);
						c.stillgfx(623, c.absY, c.absX);
						c.stillgfx(186, c.absY, c.absX);
					}
					if (c.playerEquipment[c.playerCape] == 3759) {
						c.actionTimer = 8;
						c.startAnimation(1331);
						c.stillgfx(444, c.absY, c.absX);
						c.stillgfx(441, c.absY, c.absX);
						c.txt4 = "I Feal The Power In This Cape !!!";
					}
					if (c.playerEquipment[c.playerCape] == 3765) {
						c.actionTimer = 8;
						c.startAnimation(2910);
						c.playerGfx(588, 1);
						c.playerGfx(560, 1);
						c.txt4 = "I Feal The Power In This Cape !!!";
					}
					if (c.playerEquipment[c.playerCape] == 3779) { // prayer
						c.startAnimation(1331);
						c.actionTimer = 8;
						c.playerGfx(465, 0);
						c.stillgfx(84, c.absY, c.absX);
						c.stillgfx(264, c.absY, c.absX);
						c.stillgfx(264, c.absY, c.absX);
						c.stillgfx(568, c.absY, c.absX);
						c.stillgfx(569, c.absY, c.absX);
						c.stillgfx(593, c.absY, c.absX);
					}
					if (c.playerEquipment[c.playerCape] == 3763) {
						c.actionTimer = 8;
						c.startAnimation(1979);
						c.stillgfx(559, c.absY + 1, c.absX);
						c.stillgfx(559, c.absY - 1, c.absX);
						c.stillgfx(559, c.absY, c.absX + 1);
						c.stillgfx(559, c.absY, c.absX - 1);
						c.stillgfx(451, c.absY + 1, c.absX);
						c.stillgfx(451, c.absY - 1, c.absX);
						c.stillgfx(451, c.absY, c.absX + 1);
						c.stillgfx(451, c.absY, c.absX - 1);
						c.playerGfx(503, 0);
						c.txt4 = "I Feal The Magic!!!";
					}
					if (c.playerEquipment[c.playerCape] == 3781) {
						c.actionTimer = 8;
						c.startAnimation(2890);
						c.stillgfx(346, c.absY, c.absX); // Pretty basic ones, only contain GFX, all the more fun for people who want to customize them and make their own
						c.stillgfx(427, c.absY, c.absX);
						c.stillgfx(83, c.absY, c.absX);
						c.txt4 = "I Feal The Power In This Cape !!!";

					}
					if (c.playerEquipment[c.playerCape] == 3783) {
						c.actionTimer = 8;
						c.startAnimation(1110);
						c.playerGfx(442, 1);
						c.playerGfx(482, 1);
						c.playerGfx(497, 1);
						c.txt4 = "I Feal The Power In This Cape !!!";
					}
				}
				break;
			case 169: // no emote
				c.startAnimation(0x358);
				break;
			case 162: // think emote
				c.startAnimation(0x359);
				break;
			case 164: // bow emote
				c.startAnimation(0x35A);
				break;
			case 165: // angry emote
				c.startAnimation(0x35B);
				break;
			case 161: // cry emote
				c.startAnimation(0x35C);
				break;
			case 170: // laugh emote
				c.startAnimation(0x35D);
				break;
			case 171: // cheer emote
				c.startAnimation(0x35E);
				break;
			case 163: // wave emote
				c.startAnimation(0x35F);
				break;
			case 167: // beckon emote
				c.startAnimation(0x360);
				break;
			case 172: // clap emote
				c.startAnimation(0x361);
				break;
			case 166: // dance emote
				c.startAnimation(0x362);
				break;
			case 52050: // panic emote
				c.startAnimation(0x839);
				break;
			case 52051: // jig emote
				c.startAnimation(0x83A);
				break;
			case 52052: // spin emote
				c.startAnimation(0x83B);
				break;
			case 52053: // headbang emote
				c.startAnimation(0x83C);
				break;
			case 52054: // joy jump emote
				c.startAnimation(0x83D);
				break;
			case 52055: // rasp' berry emote
				c.startAnimation(0x83E);
				break;
			case 52056: // yawn emote
				c.startAnimation(0x83F);
				break;
			case 52057: // salute emote
				c.startAnimation(0x840);
				break;
			case 52058: // shrug emote
				c.startAnimation(0x841);
				break;
			case 43092: // blow kiss emote
				c.startAnimation(0x558);
				break;
			case 2155: // glass box emote
				c.startAnimation(0x46B);
				break;
			case 25103: // climb rope emote
				c.startAnimation(0x46A);
				break;
			case 25106: // lean emote
				c.startAnimation(0x469);
				break;
			case 2154: // glass wall emote
				c.startAnimation(0x468);
				break;
			case 52071: // goblin bow emote
				c.startAnimation(0x84F);
				break;
			case 52072: // goblin dance emote
				c.startAnimation(0x850);
				break;
			case 9125: // Accurate
			case 22228: // punch (unarmed)
			case 48010: // flick (whip)
			case 21200: // spike (pickaxe)
			case 1080: // bash (staff)
			case 6168: // chop (axe)
			case 6236: // accurate (long bow)
			case 17102: // accurate (darts)
			case 8234: // stab (dagger)
				c.FightType = 1;
				c.SkillID = 0;
				break;
			case 9126: // Defensive
			case 48008: // deflect (whip)
			case 22229: // block (unarmed)
			case 21201: // block (pickaxe)
			case 1078: // focus - block (staff)
			case 6169: // block (axe)
			case 33019: // fend (hally)
			case 18078: // block (spear)
			case 8235: // block (dagger)
				c.FightType = 4;
				c.SkillID = 1;
				break;
			case 9127: // Controlled
			case 48009: // lash (whip)
			case 33018: // jab (hally)
			case 6234: // longrange (long bow)
			case 18077: // lunge (spear)
			case 18080: // swipe (spear)
			case 18079: // pound (spear)
			case 17100: // longrange (darts)
				c.FightType = 3;
				c.SkillID = 3;
				break;
			case 9128: // Aggressive
			case 22230: // kick (unarmed)
			case 21203: // impale (pickaxe)
			case 21202: // smash (pickaxe)
			case 1079: // pound (staff)
			case 6171: // hack (axe)
			case 6170: // smash (axe)
			case 33020: // swipe (hally)
			case 6235: // rapid (long bow)
			case 17101: // repid (darts)
			case 8237: // lunge (dagger)
			case 8236: // slash (dagger)
				c.FightType = 2;
				c.SkillID = 2;
				break;
			case 9154: // Log out
				//System.out.println("Logout");
				if (c.InArena) {
					c.sendMessage("You cannot logout here!");
				}
				else if (!c.InArena && !c.inGame()) {
					c.savePlayerSql();
					c.logout();
				}
				if (c.inGame()) {
					c.sendMessage("You cannot logout here!");
				}
				else if (!c.InArena && !c.inGame()) {
					c.savePlayerSql();
					c.logout();
				}						 
				break;
			case 21011:
				c.takeAsNote = false;
				break;
			case 21010:
				c.takeAsNote = true;
				break;
			case 13092:
				if (c.actionTimer <= 0) {
					if (c.tradeWith > 0) {
						if (PlayerHandler.getInstance().getPlayer(c.tradeWith).tradeStatus == 2) {
							c.tradeStatus = 3;
							c.sendFrame126("Waiting for other player...", 3431);
						}
						else if (PlayerHandler.getInstance().getPlayer(c.tradeWith).tradeStatus == 3) {
							c.tradeStatus = 3;
							// TradeGoConfirm();
						}
					}
				}
				break;
			case 13218:
				if (c.actionTimer <= 0) {
					if (c.tradeWith > 0) {
						if (PlayerHandler.getInstance().getPlayer(c.tradeWith).tradeStatus == 3) {
							c.tradeStatus = 4;
							c.sendFrame126("Waiting for other player...", 3535);
						}
						else if (PlayerHandler.getInstance().getPlayer(c.tradeWith).tradeStatus == 4) {
							c.tradeStatus = 4;
							// ConfirmTrade();
						}
					}
				}
				break;
			case 1097:
				c.setSidebarInterface(0, 1829);
				break;
			case 7212:
				c.setSidebarInterface(0, 328);
				break;
			/* AutoCast Cases ~holy */
			
			/* Prayer Cases*/
			default:
				// System.out.println("Player stands in: X="+c.absX+" Y="+c.absY);
				c.println_debug("Case 185: Action Button: " + c.actionButtonId);
				break;
		}
	}
}
